package com.example.chapter3.service.iml;

import com.example.chapter3.dao.UserDao;
import com.example.chapter3.entity.User;
import com.example.chapter3.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class LoginServiceIml implements LoginService {
    @Autowired
    UserDao userDao;

    @Override
    public boolean login(String username, String password) {
        User user = userDao.getUserByName(username);
        if (user == null) {
            log.info("用户名密码无效");
            return false;
        }else if (user.getPassword().equals(password)) {
            log.info("登陆成功");
            return true;
        }
        log.info("登陆失败");
        return false;
    }
}